#include "NotQuery.h"
#include "Query.h"
#include "QueryResult.h"
#include "Sentence.h"

QueryResult NotQuery::eval(const TextQuery &tq) const{
    QueryResult result = query.eval(tq);
    //先找到单词出现的所有句子序号(迭代器区分序号区间)
    auto beg = result.begin(), end = result.end();
    auto ret_idxs = make_shared<std::set<int>>(); 
    size_t N = result.get_file()->size();  
 
    for(size_t idx = 1; idx < N; idx++){
        if(idx != *beg || beg == end){
            ret_idxs->emplace(idx);
        }
        else if(beg != end){
            beg++;
        }
    }   
    return QueryResult(rep(),ret_idxs,result.get_file());
}
